package com.kgcx.coupon.enums;

import com.kgcx.common.log.Log;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 广告状态枚举
 * @author panjin.
 * @date 2017/12/18.
 */
@Getter
@AllArgsConstructor
@Slf4j
public enum AdStatusEnum {

    DISABLED(0, "停用"),
    ENABLED(1, "启用");

    /**
     *  编码
     */
    private int code;

    /**
     * 字段含义
     */
    private String message;

    /**
     * 获取枚举类型
     * @param code 枚举编码
     * @return
     */
    public static AdStatusEnum getEnum(int code) {
        for (AdStatusEnum item : AdStatusEnum.values()) {
            if (code == item.getCode()) {
                return item;
            }
        }
        log.warn(Log.op("get ad status enum").msg("code param is out of range").kv("code", code).toString());
        return null;
    }
}
